From f347cc1e4ae32289198d698f05f84119a708b599 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 17 May 2022 22:51:36 +0200 Subject: fix: convert undefined into null inside GetStaticProps Next.js was complaining because it cannot serialize undefined values. --- src/pages/thematique/[slug].tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/pages/thematique/[slug].tsx') diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 23e6a8b..9586f77 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -218,14 +218,15 @@ export const getStaticProps: GetStaticProps = async ({ const allThematics = allThematicsEdges.edges.map((edge) => getPageLinkFromRawData(edge.node) ); + const allThematicsLinks = allThematics.filter( + (thematic) => thematic.slug !== (params!.slug as ThematicParams['slug']) + ); const translation = await loadTranslation(locale); return { props: { currentThematic: JSON.parse(JSON.stringify(currentThematic)), - thematics: allThematics.filter( - (thematic) => thematic.slug !== (params!.slug as ThematicParams['slug']) - ), + thematics: JSON.parse(JSON.stringify(allThematicsLinks)), translation, }, }; -- cgit v1.2.3